{include file="public/base" /}
{block name="main"}
<link rel="stylesheet" href="__PUBLIC__/admin/layui/css/layui.css"  media="all">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form method="get" action="javascript:;" class="form-horizontal">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">旧密码</label>
                            <div class="col-sm-10">
                                <input type="password" name="old_password" style="width:300px" class="form-control" placeholder="请输入旧密码" value="" >
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">新密码</label>
                            <div class="col-sm-10">
                                <input type="password" name="password" style="width:300px" class="form-control" placeholder="请输入新密码" value="" >
                            </div>
                        </div>
	       <div class="form-group">
                            <label class="col-sm-2 control-label">确认密码</label>
                            <div class="col-sm-10">
                                <input type="password" name="new_password" style="width:300px" class="form-control" placeholder="请输入确认密码" value="" >
                            </div>
                        </div>
                        <div id="zhi"></div>
                        <div class="row cl">
            	           <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
                        	<div id="check" class="btn btn-primary radius"> 保存</div>
                         </div>
                      </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="javascript"}
<script src="ADMIN_JS/content.min.js?v=1.0.0"></script>
<script src="ADMIN_JS/plugins/iCheck/icheck.min.js"></script>

<script>
    //提交修改
    $("#check").click(function(){
        var old_password = $("[name='old_password']").val();
        var password = $("[name='password']").val();
        var new_password = $("[name='new_password']").val();
        if(old_password ==''){
            layer.msg("旧密码不能为空",{icon:5,time:1500});
            return false;
        }
        if(password ==''){
            layer.msg("新密码不能为空",{icon:5,time:1500});
            return false;
        }
        if(new_password ==''){
            layer.msg("确认密码不能为空",{icon:5,time:1500});
            return false;
        }
      	if(old_password == password){
            layer.msg("新密码不能与旧密码一样",{icon:5,time:1500});
            return false;
        }
        if(password != new_password){
            layer.msg("新密码与确认密码不一样",{icon:5,time:1500});
            return false;
        }
        $.ajax({
            type:'post',
            url:'{:url("login/loginedit")}',
            data:{'old_password':old_password,'password':password},
            datatype:'json',
            success:function(content){
                if(content.code == 1){
                    layer.msg(content.msg,{icon:6,time:1500});
                    setTimeout(function(){window.location.href="{:url('login/out')}"},1500);
                }
                else{
                    layer.msg(content.msg,{icon:5,time:1500});
                    refreshVerify();
                }
            },
            error:function(){
                alert("错误");
            }
        })
    })

</script>

{/block}